<template> 
  <div id="TPC">
    <table style="border:1px solid black">
      <tr>
        <th>名字</th>
        <th><input style="height:1.0667rem;border:none;outline:0;text-align:center" type="text" placeholder="请修改老师名字" v-model='questObj.teac'></th>
      </tr>
      <tr>
         <th>头像</th>
        <th>
          <el-upload
            style="margin-top:0.2667rem"
            class="avatar-uploader"
            action="http://125.210.160.93:8080/SmEdu/pass/clas/update"
            :show-file-list="false"
            name=files
            :before-upload="beforeAvatarUpload"
            :data='questObj'
            :on-success="handleAvatarSuccess"
            >
            <img v-if="imageUrl" :src="imageUrl" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload> 
   
        </th>
      </tr>
    </table>
     
    
 
  </div>
</template>
<script>
  export default {
     data() {
      return {
        imageUrl: '',
        questObj:{
          clasId:1068,
           teac:''
          // teac:'熊化鑫11'
        },
       
      };
    },
    methods: {
      handleAvatarSuccess(res, file) {
        this.imageUrl = URL.createObjectURL(file.raw);
      },
      beforeAvatarUpload(file) {
         var h1=document.getElementsByTagName('h6')[0].innerHTML;
         //console.log(parseInt(h1));
         this.questObj.clasId=parseInt(h1);
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
      }
    }
  }
</script>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 2.8733rem;
    height: 2.8733rem;
    line-height: 2.8733rem;
    text-align: center;
  }
  .avatar {
    width: 2.8733rem;
    height: 2.8733rem;
    display: block;
  }
  .el-message-box{
    width:90% !important;
}
  #TPC table{
  border-collapse:collapse;
  margin:0 auto;
}
  #TPC table tr th{
    border:1px solid black;
    height:1.3333rem;
    width:20%;
  }
</style>